/**
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@use "sass:color";

@keyframes indeterminate-progress-animation {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(200%);
  }
}

.background {
  pointer-events: all;
  border-radius: 20px;
  max-width: 95vw;
  min-width: 1200px;
  min-height: 700px;
  overflow: hidden;
  background-color: #f8f8f8;
  box-shadow: 0px 5px 15px 0px rgba(0, 0, 0, 0.35);
  display: flex;
  z-index: 999;

  ::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 7px;
  }

  ::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: #3f51b5;
    box-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
  }

  @media (max-width: 1200px) {
    min-width: 1000px;
  }
}

.title-box {
  height: 320px;
  margin: -40px 0px 0px 0px;
  display: grid;
  grid-template-areas: "icon" "title" "version";
  grid-template-rows: 1fr auto auto;
  align-items: center;
  justify-content: center;
  text-align: center;

  .icon {
    grid-area: icon;
  }

  .title {
    grid-area: title;

    h1 {
      margin: 0px;
      color: #666666;
    }
  }

  .version {
    grid-area: version;
    color: #888;
  }
}

.body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px;

  .body-header {
    display: flex;
    justify-content: end;
    color: #666666;

    .mem-usage {
      display: flex;
      justify-content: center;
      gap: 3px;
    }
  }

  .flex-expand {
    flex: 1;
  }

  .task-group {
    display: flex;
    border-radius: 3px;
    padding: 10px;
    margin-top: 10px;

    .button-group {
      display: flex;
      width: 100%;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      gap: 20px;
    }

    .inspect-left {
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: 20px;

      .task-button {
        appearance: none;
        outline: none;
        border: none;
        background-color: #fcfcfc;
        padding: 4px 0px;
        box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.35);
        width: 300px;
        border-radius: 10px;
        display: grid;
        text-align: left;
        grid-template-columns: 15px 40px 25px 1fr 10px;
        grid-template-rows: 30px 40px;
        grid-template-areas: "leftspace icon middlespace title rightspace" "leftspace icon middlespace description rightspace";

        &.main {
          background-color: #3f51b5;
          color: white;

          &:hover {
            background-color: color.adjust(#3f51b5, $lightness: -5%);
            cursor: default;
          }

          .icon-container {
            mat-icon {
              color: white;
            }
          }

          .task-description {
            color: lightgray;
          }
        }

        &.disabled {
          background-color: darkgray;
          color: white;

          &:hover {
            background-color: darkgray;
          }
        }

        .icon-container {
          grid-area: icon;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          height: 100%;

          mat-icon {
            color: #3f51b5;
            font-size: 2.5em;
            width: 30px;
            height: 30px;
          }
        }

        .task-title {
          grid-area: title;
          margin: 0;
          line-height: 40px;
          font-weight: 600;
          font-size: 1.2em;
        }

        .task-description {
          grid-area: description;
          font-size: 0.8em;
          height: 100%;
          margin: 0;
          color: dimgray;
          display: flex;
          justify-content: center;
          flex-direction: column;
        }

        &:hover {
          cursor: pointer;
          background-color: color.adjust(white, $lightness: -3%);
        }
      }
    }

    .inspect-right {
      min-width: 420px;
      padding: 20px 20px;
      display: flex;
      flex-direction: column;

      .inspection-title {
        font-size: 1em;
        font-weight: 600;
        margin: 0;
      }

      .inspection-list {
        overflow: hidden;
        flex: 1;
        position: relative;

        .inspection-list-inner {
          position: absolute;
          overflow-y: scroll;
          top: 0px;
          left: 0px;
          right: 0px;
          bottom: 0px;
        }
      }
    }

    .task-group-header {
      margin: 2px 20px 5px 2px;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      flex-direction: column;
      text-align: center;

      .group-title {
        font-weight: 600;
        font-size: 1em;
      }

      mat-icon {
        font-size: 2.5em;
        width: 40px;
        height: 40px;
      }

      &.task-group-help {
        color: gray;
        font-weight: 600;
      }
    }

    .task-group-body {
      flex: 1;
      position: relative;
      overflow: hidden;

      .task-group-body-inner {
        position: absolute;
        top: 0px;
        left: 0px;
        right: 0px;
        bottom: 0px;
        overflow-y: hidden;
        overflow-x: auto;
      }
    }
  }
}

.task-list-loading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.task-list-empty {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  text-align: center;

  .task-list-empty-message-main {
    font-size: 1em;
    color: dimgray;
  }

  .task-list-empty-message-sub {
    font-size: 0.7em;
    color: lightgray;
    font-style: italic;
  }
}

.inspection-task {
  display: grid;
  grid-template-columns: 3px 10px 1fr auto 20px;
  grid-template-rows: 5px 20px auto auto auto 2px;
  grid-template-areas: "indicator gap-head gap-head gap-head gap-head" "indicator gap1 title phase gap2" "indicator gap1 progress progress gap2" "indicator gap-bottom-up-1 gap-bottom-up-1 time gap-bottom-up-2" "indicator commands commands commands gap-middle" "indicator gap-bottom gap-bottom gap-bottom gap-bottom";
  min-height: 50px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.3);

  .inspection-task-status-indicator {
    grid-area: indicator;
    background-color: #3f51b5;
    height: 100%;
  }

  .task-title {
    grid-area: title;
    font-size: 1.3em;
    color: dimgray;
  }

  .task-phase {
    grid-area: phase;
    text-align: right;
    font-weight: 600;
    margin: 0;

    .task-phase-inner {
      padding: 0px 10px;
      border-radius: 5px;

      &.DONE {
        color: white;
        background-color: #3f51b5;
      }

      &.RUNNING {
        color: white;
        background-color: #11aa55;
      }

      &.CANCELLED {
        color: white;
        background-color: dimgray;
      }

      &.ERROR {
        color: white;
        background-color: #ff5555;
      }
    }
  }

  .task-time {
    grid-area: time;
    font-size: 0.5em;
    color: darkgray;
    margin: 0;
  }

  .task-commands {
    grid-area: commands;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "left middle right";

    .open-button {
      grid-area: left;
      margin: 0 20px;
    }

    .icon-buttons {
      grid-area: right;
    }
  }

  .progress-container {
    grid-area: progress;

    .progress-header {
      font-size: 0.8em;
      color: dimgray;
      margin-bottom: 0px;
    }

    .progress-element {
      background: dimgray;
      position: relative;
      border-bottom: 1px lightgray;

      .progress-label {
        position: absolute;
        left: 20px;
        top: 0px;
        bottom: 0px;
        margin: 0px;
        display: flex;
        justify-content: center;

        .progress-label-inner {
          color: white;
          font-size: 0.6em;
          line-height: 1;
          margin: 0px;
        }
      }

      .progress-bar {
        background-color: #3f51b5;
        height: 10px;
      }

      .indeterminate-progress-bar {
        height: 10px;
        background-color: #3f51b5;
        width: 100%;
        position: relative;
        overflow: hidden;

        &::after {
          content: "";
          position: absolute;
          top: 0;
          left: 0;
          height: 100%;
          width: 50%;
          background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.4) 50%,
            rgba(255, 255, 255, 0) 100%
          );
          animation: indeterminate-progress-animation 1.5s infinite linear;
        }
      }
    }
  }

  .error-container {
    grid-area: progress;

    .error {
      font-weight: 600;

      .error-link {
        color: #ff5555;
        display: flex;
        padding: 0px 10px;
        align-items: center;
      }

      .error-link-icon {
        width: 10px;
        height: 10px;
        font-size: 10px;
      }
    }
  }
}

.fill-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;

  .fill-container-inner {
    position: absolute;
    top: 0px;
    bottom: 0px;
    left: 0px;
    right: 0px;
    overflow: hidden;
  }
}

.horizontal-2col-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100%;
}

.link-list-elem {
  margin: auto 0;

  .link-icon {
    margin-right: 3px;
    vertical-align: middle;
  }
}
